#!/sbin/openrc-run

# Override in /etc/conf.d/daapd
LOG_LEVEL=${LOG_LEVEL:-2}
LOG_DOMAINS=${LOG_DOMAINS:-'main,mdns,db,scan'}
FFID=${FFID:-daapd}

PIDFILE=/var/run/forked-daapd.pid

depend() {
    need avahi-dnsconfd
}

start() {
    ebegin "Starting daapd"
    start-stop-daemon --start forked-daapd \
		      --pidfile "$PIDFILE" \
		      -- \
		      -P "$PIDFILE" \
		      -d "$LOG_LEVEL" \
		      -b "$FFID" \
		      -D "$LOG_DOMAINS"
    eend $?
}

stop() {
    ebegin "Stopping daapd"
    start-stop-daemon --stop forked-daapd \
		      --pidfile "$PIDFILE"
    eend $?
}
